package com.qdu.mapper;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import java.io.IOException;
public class Top5CountByHourMapper extends Mapper<LongWritable, Text, IntWritable,IntWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] data = line.split(",");
        String[] datetime = data[0].split(" ");
        String[] hours = datetime[1].split(":");
        int hour=Integer.parseInt(hours[0]);

        int count=Integer.parseInt(data[11]);

        context.write(new IntWritable(hour),new IntWritable(count));
    }
}
